package com.remoter.context.spring.boot;

import java.io.IOException;

import com.remoter.basic.configure.IConfiguration;
import com.remoter.basic.configure.support.AbstractConfiguration;
import com.remoter.basic.context.IContext;
import com.remoter.basic.util.Final;
import com.remoter.basic.util.ServiceLoader;

/**
 * @author			koko
 * @date 			2017-08-09 17:07:42
 * @description 	类功能说明
 */
public class RemoterContextStarter {
	
	public static final String ID = RemoterContextStarter.class.getName();
	
	private final IConfiguration configuration;
	private IContext context;
	
	public RemoterContextStarter(String config){
		this.configuration = AbstractConfiguration.getConfiguration();
	}
	
	public void start(){
		this.context = ServiceLoader.getService(IContext.class,this.configuration.getOption(Final.O_VAL_CONTEXT));
	}
	
	public void close(){
		try{
			this.context.close();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
}